set more off
clear all

***************************************************************
*************************************************************** 
** locals
local out "Output/"


	
** import raw data
local main "respondi.dta"
local mturk "mturk.dta"
local prolific "prolific.dta"

use `main'

**** Indicator for country ****

gen us=0
replace us=1 if country=="Us"

label define uslabel 0 "Sweden" 1 "US"
label values us uslabel

label define trlabel 1 "R\$_{L: wait}^{H:work}$" 2 "R\$_{L: wait}^{H:wait}$" 3 "R\$_{L: work}^{H:work}$" 4 "E\$_{L: wait}^{H:work}$"
label values tr trlabel




*** Creating Dummy Variables for Demographics ***
gen female=1 
replace female=0 if gender=="Male"

gen caucasian=0
replace caucasian=1 if ethnicity=="White"

gen afam=0
replace afam=1 if ethnicity=="Black or African American"

gen employed=0
replace employed=1 if (employment<4)	

gen college=1
replace college=0 if us ==1 & education<5
replace college=0 if us ==0 & education<4


gen conservative=0
replace conservative=1 if us==1 & political==2
replace conservative=1 if us==0 & (political==2|political==8|political==6|political==3)

gen income1=0
replace income1=1 if (income==1|income==2)

gen income2=0
replace income2=1 if (income==3|income==4)

gen income3=0
replace income3=1 if (income==5|income==6)

gen income4=0
replace income4=1 if (income==7|income==8)

gen income5=0
replace income5=1 if (income==9|income==10)

gen income6=0
replace income6=1 if (income==11)


*** Creating Implemented Inequality Variable ***

gen s =0 
replace s= 0.75 if decision==1
replace s= 0.625 if decision==2
replace s= 0.5 if decision==3
replace s= 0.375 if decision==4
replace s= 0.25 if decision==5
replace s= 0.125 if decision==6


******* Figure I ******** 

preserve

gen n=1

by tr, sort :egen mean_s_pooled= mean(s)
by us tr, sort :egen mean_s_country= mean(s)
by tr, sort :egen sd_s_pooled= sd(s)
by us tr, sort :egen sd_s_country= sd(s)
by tr, sort :egen n_s_pooled= sum(n)
by us tr, sort :egen n_s_country= sum(n)

generate hi_pool = mean_s_pooled + invttail(n_s_pooled-1,0.025)*(sd_s_pooled/ sqrt(n_s_pooled))
generate low_pool = mean_s_pooled - invttail(n_s_pooled-1,0.025)*(sd_s_pooled/ sqrt(n_s_pooled))
generate hi_country = mean_s_country + invttail(n_s_country-1,0.025)*(sd_s_country/ sqrt(n_s_country))
generate low_country = mean_s_country - invttail(n_s_country-1,0.025)*(sd_s_country/ sqrt(n_s_country))

generate ustr = tr    if us == 0
replace  ustr = tr+6  if us == 1
sort ustr
gen pooltr= tr-6

twoway (bar mean_s_pooled pooltr if tr==1, bcolor(white) blcolor(navy) blwidth(medthick)) ///
	   (bar mean_s_pooled pooltr if tr==2, bcolor(olive_teal)) ///
	   (bar mean_s_pooled pooltr if tr==3, bcolor(forest_green)) ///
	   (bar mean_s_pooled pooltr if tr==4, bcolor(erose)) ///
	   (rcap hi_pool low_pool pooltr, lcolor(red)) ///
	   (bar mean_s_country ustr if tr==1 & us==0, bcolor(white) blcolor(navy) blwidth(medthick)) ///
	   (bar mean_s_country ustr if tr==2 & us==0, bcolor(olive_teal)) ///
	   (bar mean_s_country ustr if tr==3 & us==0, bcolor(forest_green)) ///
	   (bar mean_s_country ustr if tr==4 & us==0, bcolor(erose)) ///
	   (bar mean_s_country ustr if tr==1 & us==1, bcolor(white) blcolor(navy) blwidth(medthick)) ///
	   (bar mean_s_country ustr if tr==2 & us==1, bcolor(olive_teal)) ///
	   (bar mean_s_country ustr if tr==3 & us==1, bcolor(forest_green)) ///
	   (bar mean_s_country ustr if tr==4 & us==1, bcolor(erose)) ///
	   (rcap hi_country low_country ustr, lcolor(red)), legend(pos(12) ring(0) col(4) size(large) order(1 2 3 4)) legend(label(1 "  {sub:H: Work}" "R{sub:L: Wait}") label(2 "  {sub:H: Wait}" "R{sub:L: Wait}") label(3 "  {sub:H: Work}" "R{sub:L: Work}") label(4 "  {sub:H: Work}" "E{sub:L: Wait}") linegap(-1))  xtitle("") xlabel( -3 "Pooled" 2 "Sweden" 7 "United States", noticks labsize(large)) ytitle("Implemented Inequality", size(large)) ylabel(0(0.25)0.75, nogrid) plotregion(color(white)) graphregion(color(white)) 

graph export `out'Figure1.png, replace 
	   
 ***** Figure Notes *****
	   
	   tab tr us
restore

sort tr
by tr: summarize s 

ranksum s if (tr==1|tr==2), by(tr)
ranksum s if (tr==1|tr==3), by(tr)

sort tr us
by tr us: summarize s 

************ Figure II ***************

catplot tr decision if us==1 & (tr==1|tr==2|tr==3), percent(tr) recast(bar) asyvars bar(1, color(white)  lcolor(navy) lwidth(medthick)) bar(2, color(olive_teal)) bar(3, color(forest_green)) legend(pos(12) ring(0) col(3) size(medium) order(1 2 3)) legend(label(1 "  {sub:H: Work}" "R{sub:L: Wait}") label(2 "  {sub:H: Wait}" "R{sub:L: Wait}") label(3 "  {sub:H: Work}" "R{sub:L: Work}") linegap(-1))  ytitle("Percentage") ylab(0 (10) 100, nogrid) yscale(titlegap(2)) var2opts(relabel(1 `" "{it:H}:  1.40"  "{it:L}:  0.20" "' 2 `" "1.30"  "0.30" "' 3 `" "1.20"  "0.40" "' 4 `" "1.10"  "0.50" "'5 `" "1.00"  "0.60" "' 6 `" "0.90"  "0.70" "' 7 `" "0.80"  "0.80" "')) graphregion(color(white)) plotregion(color(white))
graph export `out'Figure2a.png, replace 


catplot tr decision if us==0 & (tr==1|tr==2|tr==3), percent(tr) recast(bar) asyvars bar(1, color(white)  lcolor(navy) lwidth(medthick)) bar(2, color(olive_teal)) bar(3, color(forest_green)) legend(pos(12) ring(0) col(3) size(medium) order(1 2 3)) legend(label(1 "  {sub:H: Work}" "R{sub:L: Wait}") label(2 "  {sub:H: Wait}" "R{sub:L: Wait}") label(3 "  {sub:H: Work}" "R{sub:L: Work}") linegap(-1))  ytitle("Percentage") ylab(0 (10) 100, nogrid) yscale(titlegap(2)) var2opts(relabel(1 `" "{it:H}:  1.40"  "{it:L}:  0.20" "' 2 `" "1.30"  "0.30" "' 3 `" "1.20"  "0.40" "' 4 `" "1.10"  "0.50" "'5 `" "1.00"  "0.60" "' 6 `" "0.90"  "0.70" "' 7 `" "0.80"  "0.80" "')) graphregion(color(white)) plotregion(color(white)) 
graph export `out'Figure2b.png, replace 

***** Figure Notes *****
	   
	   tab tr us if tr!=4

gen noredist=0
replace noredist=1 if decision==1
tab noredist tr if tr<4, column

gen fullredist=0
replace fullredist=1 if decision==7
tab fullredist tr if tr<4, column

ttest s if (tr==1|tr==4) & us==0, by(tr)
ranksum s if (tr==1|tr==4) & us==0, by(tr)
ttest s if (tr==1|tr==4) & us==1, by(tr)
ranksum s if (tr==1|tr==4) & us==1, by(tr)


********************* TABLE I ***************

gen double H = .8
replace H= 1.40 if decision==1
replace H= 1.30 if decision==2
replace H= 1.20 if decision==3
replace H= 1.10 if decision==4
replace H= 1 if decision==5
replace H= .9 if decision==6

reg s ib1.tr score1 age female college employed income if us==0, robust
eststo m1
reg s ib1.tr score1 age female college employed income if us==1, robust
eststo m2
reg s ib1.tr##i.us score1 age female college employed income, robust
eststo m3
reg H ib1.tr##i.us score1 age female college employed income, robust
eststo m4
esttab m1 m2 m3 m4 using `out'Table1.tex ///
 	, b(2) se(2) label substitute("\_" "_") /// 
	title("Implemented Inequality") /// 
	mgroups ( "Implemented Inequality \$s_i$" "\$H_i$ (in \\$)", pattern (1 0 0 1) prefix(\multicolumn{@span}{c}{) suffix(}) span ) ///
	mtitles ( "Sweden" "US" "Pooled" "Pooled") ///
	nogaps nonumbers compress /// 
	stats(N r2, labels ("No. of Obs." "R-Squared") fmt(0 2)) ///
 	star(* 0.10 ** 0.05 *** 0.01 )  /// 
	drop (score1 age female college employed income) ///
	nobaselevels interaction(" $\times$ ")style(tex) addnote("Robust SEs")  replace
	
eststo clear

*****************************************
*************  SECTION 3.2 **************
*****************************************

gen mono=1
replace mono=0 if belief1==0 & (belief2==1|belief3==1|belief4==1|belief5==1|belief6==1|belief7==1|belief8==1|belief9==1)
replace mono=0 if belief2==0 & (belief3==1|belief4==1|belief5==1|belief6==1|belief7==1|belief8==1|belief9==1)
replace mono=0 if belief3==0 & (belief4==1|belief5==1|belief6==1|belief7==1|belief8==1|belief9==1)
replace mono=0 if belief4==0 & (belief5==1|belief6==1|belief7==1|belief8==1|belief9==1)
replace mono=0 if belief5==0 & (belief6==1|belief7==1|belief8==1|belief9==1)
replace mono=0 if belief6==0 & (belief7==1|belief8==1|belief9==1)
replace mono=0 if belief7==0 & (belief8==1|belief9==1)
replace mono=0 if belief8==0 & (belief9==1)



**** Footnote 11
tab mono country, column
gen censor =0
replace censor =1 if belief1==0 & belief2==0 & belief3==0 & belief4==0 & belief5==0 & belief6==0 & belief7==0 & belief8==0 & belief9==0 
replace censor =1 if belief1==1 & belief2==1 & belief3==1 & belief4==1 & belief5==1 & belief6==1 & belief7==1 & belief8==1 & belief9==1 
tab censor country, column


****** Figure IV ********

preserve 

keep tic belief1 belief2 belief3 belief4 belief5 belief6 belief7 belief8 belief9 mono us tr 
reshape long belief, i(tic) j(guess)

by us mono guess, sort: egen choosework= mean(belief)
twoway (connected choosework guess if us==0 & mono==1, lcolor(black) lwidth(medthick)) (connected choosework guess if us==1 & mono==1, lcolor(red) lpattern(dash)), legend( pos(7) ring(0) col(2) size(medlarge) order(1 "Sweden" 2 "United States")) xlab(1(1)9,nogrid labsize(medium)) ylab(0(0.2)1, labsize(medlarge) nogrid) xtitle("Payment Scenario", size(large) margin(medium))  ytitle("Fraction of Spectators" "guessing Agent chose to {it:Work}", size(medlarge)) xlabel(1 `" "1.40" "0.20" "' 2 `" "1.30" "0.30" "' 3 `" "1.20" "0.40" "' 4`" "1.10" "0.50" "' 5`" "1.00" "0.60" "' 6`" "0.90" "0.70" "' 7 `" "0.80" "0.80" "' 8`" "0.70" "0.90" "' 9 `" "0.60" "1.00" "') plotregion(color(white)) graphregion(color(white)) text(-0.09 0 "{it: Work:}") graphregion(margin(3 15 1 3)) text(-0.15 0 "{it: Wait:}") graphregion(margin(3 15 1 3))
graph export `out'Figure4.png, replace 

restore

**** Footnote 13 

gen switch=-1
replace switch=1 if mono==1 & belief1==0
replace switch=2 if mono==1 & belief1==1 & belief2==0
replace switch=3 if mono==1 & belief2==1 & belief3==0
replace switch=4 if mono==1 & belief3==1 & belief4==0
replace switch=5 if mono==1 & belief4==1 & belief5==0
replace switch=6 if mono==1 & belief5==1 & belief6==0
replace switch=7 if mono==1 & belief6==1 & belief7==0
replace switch=8 if mono==1 & belief7==1 & belief8==0
replace switch=9 if mono==1 & belief8==1 & belief9==0
replace switch=10 if mono==1 & belief9==1

sort tr
by tr: summarize switch if mono==1


****** Table II ********

gen uneq_income =0
replace uneq_income=-1 if decision<7

label define uneq_incomelabel 0 "IH=IL" -1 "IH>IL"
label values uneq_income uneq_incomelabel


gen uneq_util=0
replace uneq_util=-1 if ((decision+1 <switch & tr==1)|(decision<7 & tr==2)|(decision<7 & tr==3)|(decision+1 <switch & tr==4))
replace uneq_util=1 if ((decision>switch & tr==1)|(decision>switch & tr==4))

label define uneq_utillabel 0 "UH=UL" -1 "UH>UL" 1 "UH<UL"
label values uneq_util uneq_utillabel

estpost tabulate uneq_util uneq_income if tr==1 & mono==1
esttab using `out'Table2.tex, cell("colpct(fmt(0))")  label substitute("\_" "_") unstack collabels(none) noobs nonumb ///
varlabels(`e(labels)') eqlabels(`e(eqlabels)') ///
title("Utility Allocations in \$R^{H:work}_{L:wait}$ by Income Allocation ")  replace
eststo clear


*****************************************
*************  Appendix A **************
*****************************************


****** TABLE A1  *********

global dem "female age caucasian afam employed college conservative income1 income2 income3 income4 income5 income6"

label var female "Female"
label var age "Age (in years)"
label var caucasian "White"
label var afam "African American"
label var employed "Employed"
label var college "College"
label var conservative "Conservative"
label var income1 "0-19,999"
label var income2 "20,000-39,999"
label var income3 "40,000-59,999"
label var income4 "60,000-79,999"
label var income5 "80,000-99,999"
label var income6 "100,000 and over"


estpost su $dem if us==0
eststo m1
estpost su $dem if us==1
eststo m2 
esttab m1 m2 using `out'TableA1.tex, replace ///
refcat(income1 "\emph{Income (in \\$)}", nolabel) ///
mtitle("Sweden" "US") ///
cells(mean(fmt(2))) label nonum collabels(none) noobs ///
title("Descriptive Statistics")

eststo clear


****** TABLE A2  *********

bysort mono us: eststo: estpost tabstat s, stat(mean ) columns(statistics) by(tr) nototal
bysort us: eststo: estpost tabstat s, stat(mean ) columns(statistics) by(tr) nototal
esttab est5 est3 est6 est4 using `out'TableA2.tex, replace ///
	cells(mean(fmt(2))) ///
    nonumbers collabels(none)  ///
    mlabels("Entire Sample" "Monotonic" "Entire Sample" "Monotonic", lhs("")) ///
    mgroups("Sweden" "US", pattern(1 0 1 0) prefix(\multicolumn{@span}{c}{) suffix(}) span  ) ///
	varlabels(`e(labels)') varwidth(40) ///
	title("Implemented Inequality: Entire Sample and Monotonic Subsample")
eststo clear

************************************************************************************************************************************************

************************************************************************************************************************************************
****** FIGURE A2  ********* 

preserve 

keep tic belief1 belief2 belief3 belief4 belief5 belief6 belief7 belief8 belief9 mono us tr 
reshape long belief, i(tic) j(guess)

by tr us mono guess, sort: egen mean_guess= mean(belief)

twoway (connected mean_guess guess if us==0 & mono==1 & tr==1, lcolor(black) lwidth(medthick)) (line mean_guess guess if us==0 & mono==1 & tr==2, lcolor(navy) lpattern(dash)) (connected mean_guess guess if us==0 & mono==1 & tr==3, lcolor(green) lpattern(dash) msymbol(circle_hollow)) (connected mean_guess guess if us==0 & mono==1 & tr==4, lcolor(red) lpattern(medthick) msymbol(Th)), legend( pos(7) ring(0) col(1) size(medlarge) order(1 2 3 4)) legend(label(1 "  {sub:H: Work}" "R{sub:L: Wait}") label(2 "  {sub:H: Wait}" "R{sub:L: Wait}") label(3 "  {sub:H: Work}" "R{sub:L: Work}") label(4 "  {sub:H: Work}" "E{sub:L: Wait}") linegap(-1))  xlab(1(1)9,nogrid labsize(medium)) ylab(0(0.2)1, labsize(medlarge) nogrid) xtitle("Payment Scenario", size(large) margin(medium))  ytitle("Fraction of Spectators" "guessing Agent chose to {it:Work}", size(medlarge)) xlabel(1 `" "1.40" "0.20" "' 2 `" "1.30" "0.30" "' 3 `" "1.20" "0.40" "' 4`" "1.10" "0.50" "' 5`" "1.00" "0.60" "' 6`" "0.90" "0.70" "' 7 `" "0.80" "0.80" "' 8`" "0.70" "0.90" "' 9 `" "0.60" "1.00" "') plotregion(color(white)) graphregion(color(white)) text(-0.09 0 "{it: Work:}") graphregion(margin(3 15 1 3)) text(-0.15 0 "{it: Wait:}") graphregion(margin(3 15 1 3)) 
graph export `out'FigureA2a.png, replace 

twoway (connected mean_guess guess if us==1 & mono==1 & tr==1, lcolor(black) lwidth(medthick)) (line mean_guess guess if us==1 & mono==1 & tr==2, lcolor(navy) lpattern(dash)) (connected mean_guess guess if us==1 & mono==1 & tr==3, lcolor(green) lpattern(dash) msymbol(circle_hollow)) (connected mean_guess guess if us==1 & mono==1 & tr==4, lcolor(red) lpattern(medthick) msymbol(Th)), legend( pos(7) ring(0) col(1) size(medlarge) order(1 2 3 4)) legend(label(1 "  {sub:H: Work}" "R{sub:L: Wait}") label(2 "  {sub:H: Wait}" "R{sub:L: Wait}") label(3 "  {sub:H: Work}" "R{sub:L: Work}") label(4 "  {sub:H: Work}" "E{sub:L: Wait}") linegap(-1))  xlab(1(1)9,nogrid labsize(medium)) ylab(0(0.2)1, labsize(medlarge) nogrid) xtitle("Payment Scenario", size(large) margin(medium))  ytitle("Fraction of Spectators" "guessing Agent chose to {it:Work}", size(medlarge)) xlabel(1 `" "1.40" "0.20" "' 2 `" "1.30" "0.30" "' 3 `" "1.20" "0.40" "' 4`" "1.10" "0.50" "' 5`" "1.00" "0.60" "' 6`" "0.90" "0.70" "' 7 `" "0.80" "0.80" "' 8`" "0.70" "0.90" "' 9 `" "0.60" "1.00" "') plotregion(color(white)) graphregion(color(white)) text(-0.09 0 "{it: Work:}") graphregion(margin(3 15 1 3)) text(-0.15 0 "{it: Wait:}") graphregion(margin(3 15 1 3)) 
graph export `out'FigureA2b.png, replace 

restore

************************************************************************************************************************************************

************************************************************************************************************************************************
****** TABLE A3  ********* 

gen disutility = 10-switch
reg s disutility score1 age female college employed income if us==0 & tr==1 & switch>-1 , robust
eststo m1  
reg s disutility score1 age female college employed income if us==1 & tr==1 & switch>-1 , robust
eststo m2
esttab m1 m2 using `out'TableA3.tex ///
 	, b(2) se(2) label substitute("\_" "_") /// 
	title("Implemented Inequality and Perceived Disutility of Working") /// 
	mgroups ( "Implemented Inequality \$s_i$ " , pattern (1 0 ) prefix(\multicolumn{@span}{c}{) suffix(}) span ) ///
	mtitles ( "Sweden" "US") ///
	nogaps nonumbers compress /// 
	stats(N r2, labels ("No. of Obs." "R-Squared") fmt(0 2)) ///
 	star(* 0.10 ** 0.05 *** 0.01 )  /// 
	drop (score1 age female college employed income) ///
	nobaselevels interaction(" $\times$ ")style(tex) addnote("Robust SEs")  replace
	
eststo clear

************************************************************************************************************************************************

************************************************************************************************************************************************
******* TABLE A4 *********

reg s ib1.tr i.us us##tr score1 age female college employed income if tr!=4 & disutility<3, robust
eststo m1
reg s ib1.tr i.us us##tr score1 age female college employed income if tr!=4 & disutility>2 & disutility<7 , robust
eststo m2
reg s ib1.tr i.us us##tr score1 age female college employed income if tr!=4 & disutility>6, robust
eststo m3
esttab m1 m2 m3 using `out'TableA4.tex ///
 	, b(2) se(2) label substitute("\_" "_") /// 
	title("Implemented Inequality by Perceived Costs of Working") /// 
	mgroups ( "Implemented Inequality \$s_i$" , pattern (1 0 0) prefix(\multicolumn{@span}{c}{) suffix(}) span ) ///
	mtitles ( "Neg. Cost" "Low Cost" "High Cost") ///
	nogaps nonumbers compress /// 
	stats(N r2, labels ("No. of Obs." "R-Squared") fmt(0 2)) ///
 	star(* 0.10 ** 0.05 *** 0.01 )  /// 
	drop (*.us score1 age female college employed income) ///
	nobaselevels interaction(" $\times$ ")style(tex) addnote("Robust SEs")  replace
	
eststo clear

************************************************************************************************************************************************

************************************************************************************************************************************************
****** FIGURE A3  *********
 
gen prefer=0
replace prefer=-1 if (decision>switch & tr==1)|(decision>7 & tr==2)|(decision>7 & tr==3)|(decision>switch & tr==4)
replace prefer=1 if (decision+1<switch & tr==1)|(decision<7 & tr==2)|(decision<7 & tr==3)|(decision+1<switch & tr==4)

gen excessincome =-1 
replace excessincome= H - 1.50 if (switch==1 & tr==1)|(switch==1 & tr==4)
replace excessincome= H - 1.40 if (switch==2 & tr==1)|(switch==2 & tr==4)
replace excessincome= H - 1.30 if (switch==3 & tr==1)|(switch==3 & tr==4)
replace excessincome= H - 1.20 if (switch==4 & tr==1)|(switch==4 & tr==4)
replace excessincome= H - 1.10 if (switch==5 & tr==1)|(switch==5 & tr==4)
replace excessincome= H - 1.00 if (switch==6 & tr==1)|(switch==6 & tr==4)
replace excessincome= H - 0.90 if (switch==7 & tr==1)|(switch==7 & tr==4)
replace excessincome= H - 0.80 if (switch==8 & tr==1)|(switch==8 & tr==4)
replace excessincome= H - 0.70 if (switch==9 & tr==1)|(switch==9 & tr==4)
replace excessincome= H - 0.60 if (switch==10 & tr==1)|(switch==10 & tr==4)

sum excessincome if tr==1 & mono==1 & prefer==1
twoway histogram excessincome if tr==1 & mono==1 & prefer==1, fraction discrete lcolor(navy) fcolor(white) lwidth(medthick) xtitle("{it:H{subscript:i}} - {it:w{subscript:r{subscript:i}-1}}", size(large)) xlabel(0(0.1)0.8,nogrid) ylabel(,nogrid) graphregion(color(white)) plotregion(color(white))
graph export `out'FigureA3.png, replace 

************************************************************************************************************************************************

************************************************************************************************************************************************
******* FIGURE A4 *********

gen utility_a=1
replace utility_a=2 if ((decision+1 <switch & tr==1)|(decision<7 & tr==2)|(decision<7 & tr==3)|(decision+1 <switch & tr==4))
replace utility_a=3 if ((decision>switch & tr==1)|(decision>switch & tr==4))

catplot tr utility_a if mono==1 & us==0 & (tr==1|tr==2|tr==3), percent(tr) recast(bar) asyvars bar(1, color(white)  lcolor(navy) lwidth(medthick)) bar(2, color(olive_teal)) bar(3, color(forest_green)) legend(pos(12) ring(0) col(3) size(huge) order(1 2 3)) legend(label(1 "  {sub:H: Work}" "R{sub:L: Wait}") label(2 "  {sub:H: Wait}" "R{sub:L: Wait}") label(3 "  {sub:H: Work}" "R{sub:L: Work}") linegap(-1))  ytitle("Percentage") ylab(0 (20) 100, nogrid) yscale(titlegap(2)) var2opts(relabel(1`" "U{subscript:H} = U{subscript:L}" "' 2`" "U{subscript:H} > U{subscript:L}" "' 3`" "U{subscript:H} < U{subscript:L}" "')) graphregion(color(white)) plotregion(color(white))
graph export `out'FigureA4a.png, replace

catplot tr utility_a if mono==1 & us==1 & (tr==1|tr==2|tr==3), percent(tr) recast(bar) asyvars bar(1, color(white)  lcolor(navy) lwidth(medthick)) bar(2, color(olive_teal)) bar(3, color(forest_green)) legend(pos(12) ring(0) col(3) size(huge) order(1 2 3)) legend(label(1 "  {sub:H: Work}" "R{sub:L: Wait}") label(2 "  {sub:H: Wait}" "R{sub:L: Wait}") label(3 "  {sub:H: Work}" "R{sub:L: Work}") linegap(-1))  ytitle("Percentage") ylab(0 (20) 100, nogrid) yscale(titlegap(2)) var2opts(relabel(1`" "U{subscript:H} = U{subscript:L}" "' 2`" "U{subscript:H} > U{subscript:L}" "' 3`" "U{subscript:H} < U{subscript:L}" "')) graphregion(color(white)) plotregion(color(white))
graph export `out'FigureA4b.png, replace

*****************************************
*************  Appendix B **************
*****************************************

******* FIGURE B1 *********

preserve 

gen n=1

by tr type, sort :egen mean_s_type= mean(s)
by tr type, sort :egen sd_s_type= sd(s)
by tr type, sort :egen n_s_type= sum(n)
generate hi_type = mean_s_type + invttail(n_s_type-1,0.025)*(sd_s_type / sqrt(n_s_type))
generate low_type = mean_s_type - invttail(n_s_type-1,0.025)*(sd_s_type / sqrt(n_s_type))

generate typetr = tr    if type == 3
replace  typetr = tr+5  if type== 2
replace  typetr = tr+10  if type== 1
sort typetr

twoway (bar mean_s_type typetr if type==3 & tr==1, bcolor(white) blcolor(navy) blwidth(medthick)) ///
	   (bar mean_s_type typetr if type==3 & tr==2, bcolor(olive_teal)) ///
	   (bar mean_s_type typetr if type==3 & tr==3, bcolor(forest_green)) ///
	   (bar mean_s_type typetr if type==3 & tr==4, bcolor(erose)) ///
	   (rcap hi_type low_type typetr if type==3, lcolor(red)) ///
	   (bar mean_s_type typetr if type==2 & tr==1, bcolor(white) blcolor(navy) blwidth(medthick)) ///
	   (bar mean_s_type typetr if type==2 & tr==2, bcolor(olive_teal)) ///
	   (bar mean_s_type typetr if type==2 & tr==3, bcolor(forest_green)) ///
	   (bar mean_s_type typetr if type==2 & tr==4, bcolor(erose)) ///
	   (rcap hi_type low_type typetr if type==2, lcolor(red)) ///
	   (bar mean_s_type typetr if type==1 & tr==1, bcolor(white) blcolor(navy) blwidth(medthick)) ///
	   (bar mean_s_type typetr if type==1 & tr==2, bcolor(olive_teal)) ///
	   (bar mean_s_type typetr if type==1 & tr==3, bcolor(forest_green)) ///
	   (bar mean_s_type typetr if type==1 & tr==4, bcolor(erose)) ///
	   (rcap hi_type low_type typetr if type==1, lcolor(red)), legend(pos(12) ring(0) col(4) size(large) order(1 2 3 4)) legend(label(1 "  {sub:H: Work}" "R{sub:L: Wait}") label(2 "  {sub:H: Wait}" "R{sub:L: Wait}") label(3 "  {sub:H: Work}" "R{sub:L: Work}") label(4 "  {sub:H: Work}" "E{sub:L: Wait}") linegap(-1))  xtitle("") ytitle("Implemented Inequality", size(large) margin(medsmall)) ylabel(0(0.25)0.75, nogrid) xlabel(2.5 "Libertarian" 7.5 "Egalitarian" 12.5 "Meritocrat", noticks labsize(large))  plotregion(color(white)) graphregion(color(white)) 
graph export `out'FigureB1.png, replace 


restore

************************************************************************************************************************************************

************************************************************************************************************************************************
******* TABLE B1 *********

label define fairnesstypelabel 1 "Meritocrat" 2 "Egalitarian" 3 "Libertarian" 
label values type fairnesstypelabel

reg s ib2.type us score1 age female college employed income  if tr==1, robust
eststo m1
reg s ib2.type us score1 age female college employed income  if tr==2, robust
eststo m2
reg s ib2.type us score1 age female college employed income if tr==3, robust
eststo m3
reg s ib2.type us score1 age female college employed income if tr==4, robust
eststo m4
esttab m1 m2 m3 m4 using `out'TableB1.tex ///
 	, b(2) se(2) label substitute("\_" "_") /// 
	title("Income Inequality across Fairness Views") /// 
	mgroups ( "Implemented Inequality \$s_i$", pattern (1 0 0 0) prefix(\multicolumn{@span}{c}{) suffix(}) span ) ///
	mtitles ( "\$R^{H:work}_{L:wait}$" "\$R^{H:wait}_{L:wait}$ " "\$R^{H:work}_{L:work}$ " "\$E^{H:work}_{L:wait}$ ") ///
	nogaps nonumbers compress /// 
	stats(N r2, labels ("No. of Obs." "R-Squared") fmt(0 2)) ///
 	star(* 0.10 ** 0.05 *** 0.01 )  /// 
	drop (us score1 age female college employed income) ///
	nobaselevels interaction(" $\times$ ")style(tex) addnote("Robust SEs")  replace

eststo clear

************************************************************************************************************************************************

************************************************************************************************************************************************
******* TABLE B2 *********

reg s ib1.tr##i.us score1 age female college employed income if type==3, robust
eststo m1
reg s ib1.tr##i.us score1 age female college employed income if type==2, robust
eststo m2
reg s ib1.tr##i.us score1 age female college employed income if type==1, robust
eststo m3
esttab m1 m2 m3 using `out'TableB2.tex ///
 	, b(2) se(2) label substitute("\_" "_") /// 
	title("Income Inequality across Treatments by Fairness Views") /// 
	mgroups ( "Implemented Inequality \$s_i$", pattern (1 0 0) prefix(\multicolumn{@span}{c}{) suffix(}) span ) ///
	mtitles ( "Libertarian" "Egalitarian" "Meritocrat") ///
	nogaps nonumbers compress /// 
	stats(N r2, labels ("No. of Obs." "R-Squared") fmt(0 2)) ///
 	star(* 0.10 ** 0.05 *** 0.01 )  /// 
	drop (*.us score1 age female college employed income) ///
	nobaselevels interaction(" $\times$ ")style(tex) addnote("Robust SEs")  replace

eststo clear

************************************************************************************************************************************************

************************************************************************************************************************************************
******* TABLE B3 *********

gen high_inc=0
replace high_inc=1 if income>6


reg s ib1.tr##i.us score1 age female college employed income  if conservative==1, robust
eststo m1
reg s ib1.tr##i.us score1 age female college employed income if conservative==0, robust
eststo m2
reg s ib1.tr##i.us score1 age college employed income if female==0, robust
eststo m3
reg s ib1.tr##i.us score1 age college employed income if female==1, robust
eststo m4
reg s ib1.tr##i.us score1 age female  employed  income if college==1, robust
eststo m5
reg s ib1.tr##i.us score1 age female  employed  income if college==0, robust
eststo m6
reg s ib1.tr##i.us score1 age college employed income if high_inc==0, robust
eststo m7
reg s ib1.tr##i.us score1 age college employed income if high_inc==1, robust
eststo m8
esttab m1 m2 m3 m4 m5 m6 m7 m8 using `out'TableB3.tex ///
 	, b(2) se(2) label substitute("\_" "_") /// 
	title("Predicting Income Inequality by Pol...") /// 
	mgroups ( "Implemented Inequality \$s_i$", pattern (1 0 0 0 0 0 0 0) prefix(\multicolumn{@span}{c}{) suffix(}) span ) ///
	mtitles ( "Cons" "Non-Cons" "Male" "Female" "College" "No College" "Low Income" "High Income") ///
	nogaps nonumbers compress /// 
	stats(N r2, labels ("No. of Obs." "R-Squared") fmt(0 2)) ///
 	star(* 0.10 ** 0.05 *** 0.01 )  /// 
	drop (*.us 2.tr#1.us 3.tr#1.us 4.tr#1.us score1 age female college employed income) ///
	nobaselevels interaction(" $\times$ ")style(tex) addnote("Robust SEs")  replace

eststo clear

************************************************************************************************************************************************

************************************************************************************************************************************************
******* TABLE B4 ********* 

**** Panel A ****

reg s redistribute if us==0, robust
eststo m1
reg s redistribute if us==1, robust
eststo m2

**** Panel B ****

reg s conservative if us==0, robust
eststo m3
reg s conservative if us==1, robust
eststo m4

**** Panel C ****

reg s female if us==0, robust
eststo m5
reg s female if us==1, robust
eststo m6


local gops      b(2) se(2) label ///
                starlevel(* 0.10 ** 0.05 *** 0.01) staraux ///
                fragment booktabs
				
				
local preheadA  "\begin{tabular}{l*{@M}{c}} \hline" //only need in first panel
local postheadA "\hline \multicolumn{@span}{l}{\textbf{Panel A: Support for Redistribution }} \\"

esttab          m1 m2 ///
                using `out'TableB4tex, replace ///
                `gops' ///
                mtitle("Sweden" "US") ///
                prehead(`preheadA') posthead(`postheadA')
				
local postheadB "\hline \multicolumn{@span}{l}{\textbf{Panel B: Political Orientation}} \\"

esttab          m3 m4 ///
                using `out'TableB4tex, append ///
                `gops' ///
                nonumber nomtitle ///
                posthead(`postheadB')
				
loc postheadC   "\hline \multicolumn{@span}{l}{\textbf{Panel C: Gender}} \\"               
local postfootC "\hline \end{tabular}"

esttab          m5 m6 ///
                using `out'TableB4tex, append ///
                `gops' ///
                nonumber nomtitle ///
                posthead(`postheadC') postfoot(`postfootC')

eststo clear

************************************************************************************************************************************************

************************************************************************************************************************************************
******* TABLE B5 ********* 

replace identical= 0 if identical==.
replace different= 0 if different==.
replace agency= 0 if agency==.

label var identical "Identical"
label var different "Different"
label var agency "Agency"

bysort us: eststo: estpost tabstat identical different agency, stat(mean)  by(tr) nototal
esttab using `out'TableB5.tex, cells("identical(fmt(2)) different(fmt(2)) agency(fmt(2))") label noobs mtitles("Sweden" "US") collabels(none) ///
varlabels(`e(labels)') varwidth(40) eqlabels(`e(eqlabels)') ///
title("Coding Proportions") replace

eststo clear

************************************************************************************************************************************************

************************************************************************************************************************************************
******* FIGURE B2 ********* 

twoway (histogram decision if tr==1 & agency==1 & us==1, fraction discrete color(gs15)) (histogram decision if tr==1 & agency==1 & us==0, fraction discrete fcolor(none) lcolor(red)), xtitle("") ytitle("Fraction of Spectators") ylabel(0(0.2)0.8) xlabel(1 `" "H: 1.40" "L: 0.20" "' 2 `" "1.30" "0.30" "' 3 `" "1.20" "0.40" "' 4`" "1.10" "0.50" "' 5`" "1.00" "0.60" "' 6`" "0.90" "0.70" "' 7 `" "0.80" "0.80" "') ylabel(,nogrid) legend(order(1 "United States" 2 "Sweden")) graphregion(color(white)) plotregion(color(white))
graph export `out'FigureB2a.png, replace 

twoway (histogram decision if tr==1 & different==1 & us==1, fraction discrete color(gs15)) (histogram decision if tr==1 & different==1 & us==0, fraction discrete fcolor(none) lcolor(red)), xtitle("") ytitle("Fraction of Spectators") ylabel(0(0.2)0.8) xlabel(1 `" "H: 1.40" "L: 0.20" "' 2 `" "1.30" "0.30" "' 3 `" "1.20" "0.40" "' 4`" "1.10" "0.50" "' 5`" "1.00" "0.60" "' 6`" "0.90" "0.70" "' 7 `" "0.80" "0.80" "') ylabel(,nogrid) legend(order(1 "United States" 2 "Sweden")) graphregion(color(white)) plotregion(color(white)) 
graph export `out'FigureB2b.png, replace 

************************************************************************************************************************************************

************************************************************************************************************************************************
******* FIGURE B3 ********* 

sort decision
cumul decision if tr==2 &us==0, gen(sweden)
cumul decision if tr==2 &us==1, gen(notsweden)
twoway (line sweden decision, lcolor(black) lwidth(thick)) (line notsweden decision, lcolor(blue) lwidth(thick) lpattern(dash)), ylab(, grid) ytitle("CDF") xtitle("") xlabel( 1 `" "1.4" "0.2" "' 2 `" "1.3"  "0.3" "' 3 `" "1.2"  "0.4" "' 4 `" "1.1"  "0.5" "'5 `" "1.0"  "0.6" "' 6 `" "0.9"  "0.7" "' 7 `" "0.8"  "0.8" "', noticks nogrid)   graphregion(color(white) margin(zero )) plotregion(color(white) margin(zero )) legend(label(1 "Sweden") label(2 "US") linegap(-1)) subtitle("  {sub:H: Wait}" "R{sub:L: Wait}")
graph export `out'FigureB3a.png, replace 
drop sweden notsweden

sort decision
cumul decision if tr==3 &us==0, gen(sweden)
cumul decision if tr==3 &us==1, gen(notsweden)
twoway (line sweden decision, lcolor(black) lwidth(thick)) (line notsweden decision, lcolor(blue) lwidth(thick) lpattern(dash)), ylab(, grid) ytitle("CDF") xtitle("") xlabel( 1 `" "1.4" "0.2" "' 2 `" "1.3"  "0.3" "' 3 `" "1.2"  "0.4" "' 4 `" "1.1"  "0.5" "'5 `" "1.0"  "0.6" "' 6 `" "0.9"  "0.7" "' 7 `" "0.8"  "0.8" "', noticks nogrid)   graphregion(color(white) margin(zero )) plotregion(color(white) margin(zero )) legend(label(1 "Sweden") label(2 "US") linegap(-1)) subtitle("  {sub:H: Work}" "R{sub:L: Work}")
graph export `out'FigureB3b.png, replace 
drop sweden notsweden

************************************************************************************************************************************************

************************************************************************************************************************************************
******* FIGURE B4 ********* 

gen est_encode= score1*1.5

twoway histogram est_encode if tr==1, discrete percent fcolor(gs15) lcolor(black) xlabel(0(5)50) xtitle("Letters Encoded",size(medlarge)) graphregion(color(white)) plotregion(color(white)) 
graph export `out'FigureB4.png, replace 






**********************************************************************************************************************************************************
************************************************************************ MTURK STUDY **********************************************************************
***********************************************************************************************************************************************************

clear all

use `mturk'

label define distlabel 0 "Redistribution" 1 "Distribution"
label values dist distlabel

label define trlabel 1 "\$R_{L: wait}^{H:work}$" 2 "\$R_{L: wait}^{H:wait}$" 3 "\$R_{L: work}^{H:work}$" 4 "\$E_{L: wait}^{H:work}$"
label values tr trlabel

tab dist

*** Creating Implemented Inequality Variable ***

gen s =0 
replace s= 0.75 if decision==1
replace s= 0.625 if decision==2
replace s= 0.5 if decision==3
replace s= 0.375 if decision==4
replace s= 0.25 if decision==5
replace s= 0.125 if decision==6
replace s= 0.75 if decision==13
replace s= 0.625 if decision==12
replace s= 0.5 if decision==11
replace s= 0.375 if decision==10
replace s= 0.25 if decision==9
replace s= 0.125 if decision==8

gen double H = .8
replace H= 1.4 if decision==1
replace H= 1.3 if decision==2
replace H= 1.2 if decision==3
replace H= 1.1 if decision==4
replace H= 1 if decision==5
replace H= 0.9 if decision==6
replace H= 0.7 if decision==8
replace H= 0.6 if decision==9
replace H= 0.5 if decision==10
replace H= 0.4 if decision==11
replace H= 0.3 if decision==12
replace H= 0.2 if decision==13


*** Demographics ***

gen female=0
replace female=1 if gender==1

gen college=1
replace college=0 if  education<5

gen employed=0
replace employed=1 if (employment<4)

gen conservative=0
replace conservative=1 if political==2	



sort tr
by tr: summarize s if dist==0

****** Figure V ******* 
gen n=1

by tr dist, sort :egen mean_s= mean(s)
by tr, sort :egen sds= sd(s)
by tr, sort :egen ns= sum(n)
generate his = mean_s + invttail(ns-1,0.025)*(sds / sqrt(ns))
generate los = mean_s - invttail(ns-1,0.025)*(sds / sqrt(ns))

**** Figure V(a) ******

twoway (bar mean_s tr if dist==0 & tr==1, bcolor(white) blcolor(navy) blwidth(medthick)) ///
	   (bar mean_s tr if dist==0 & tr==2, bcolor(olive_teal)) ///
	   (bar mean_s tr if dist==0 & tr==3, bcolor(forest_green)) ///
	   (bar mean_s tr if dist==0 & tr==4, bcolor(erose)) ///
(rcap his los tr if dist==0, lcolor(red)), legend(pos(12) ring(0) col(4) size(large) order(1 2 3 4)) legend(label(1 "  {sub:H: Work}" "R{sub:L: Wait}") label(2 "  {sub:H: Wait}" "R{sub:L: Wait}") label(3 "  {sub:H: Work}" "R{sub:L: Work}") label(4 "  {sub:H: Work}" "E{sub:L: Wait}") linegap(-1))  xtitle("") ytitle("Implemented Inequality", size(large) margin(medsmall)) ylabel(0(0.25)0.75, nogrid) xlabel(none)  plotregion(color(white)) graphregion(color(white))
graph export `out'Figure5a.png, replace  

**** Figure V(b) ******

twoway (bar mean_s tr if dist==1 & tr==1, bcolor(white) blcolor(navy) blwidth(medthick)) ///
	   (bar mean_s tr if dist==1 & tr==2, bcolor(olive_teal)) ///
	   (bar mean_s tr if dist==1 & tr==3, bcolor(forest_green)) ///
	   (bar mean_s tr if dist==1 & tr==4, bcolor(erose)) ///
(rcap his los tr if dist==1, lcolor(red)), legend(pos(12) ring(0) col(4) size(large) order(1 2 3 4)) legend(label(1 "  {sub:H: Work}" "R{sub:L: Wait}") label(2 "  {sub:H: Wait}" "R{sub:L: Wait}") label(3 "  {sub:H: Work}" "R{sub:L: Work}") label(4 "  {sub:H: Work}" "E{sub:L: Wait}") linegap(-1))  xtitle("") ytitle("Implemented Inequality", size(large)margin(medsmall)) ylabel(0(0.25)0.75, nogrid) xlabel(none) plotregion(color(white)) graphregion(color(white)) 
graph export `out'Figure5b.png, replace 

*** Figure Notes ***

tab tr dist

************************************************************************************************************************************************

************************************************************************************************************************************************
********** Table III ************ 

reg s ib1.tr score1 age female college employed income if dist==0, robust
eststo m1
reg s ib1.tr score1 age female college employed income if dist==1, robust
eststo m2
reg H ib1.tr score1 age female college employed income if dist==0, robust
eststo m3
reg H ib1.tr score1 age female college employed income if dist==1, robust
eststo m4
estout m1 m2 m3 m4, cells(b(star fmt(2)) se(par fmt(2))) starlevels( * 0.10 ** 0.05 *** 0.010) stats(N r2, labels ("No. of Obs." "R-Squared") fmt(2)) 
esttab m1 m2 m3 m4 using `out'Table3.tex ///
 	, b(2) se(2) label substitute("\_" "_") /// 
	title("Implemented Inequality: Redistribution and Distribution") /// 
	mgroups ( "Implemented Inequality \$s_i$" "\$H_i$ (in \\$)", pattern (1 0 1 0) prefix(\multicolumn{@span}{c}{) suffix(}) span ) ///
	mtitles ( "Redist" "Dist" "Redist" "Dist") ///
	nogaps nonumbers compress /// 
	stats(N r2, labels ("No. of Obs." "R-Squared") fmt(0 2)) ///
 	star(* 0.10 ** 0.05 *** 0.01 )  /// 
	drop (score1 age female college employed income) ///
	nobaselevels interaction(" $\times$ ")style(tex) addnote("Robust SEs")  replace
	
eststo clear
************************************************************************************************************************************************

************************************************************************************************************************************************
*** Table A5 ****

gen mono=1
replace mono=0 if belief1==0 & (belief2==1|belief3==1|belief4==1|belief5==1|belief6==1|belief7==1|belief8==1|belief9==1)
replace mono=0 if belief2==0 & (belief3==1|belief4==1|belief5==1|belief6==1|belief7==1|belief8==1|belief9==1)
replace mono=0 if belief3==0 & (belief4==1|belief5==1|belief6==1|belief7==1|belief8==1|belief9==1)
replace mono=0 if belief4==0 & (belief5==1|belief6==1|belief7==1|belief8==1|belief9==1)
replace mono=0 if belief5==0 & (belief6==1|belief7==1|belief8==1|belief9==1)
replace mono=0 if belief6==0 & (belief7==1|belief8==1|belief9==1)
replace mono=0 if belief7==0 & (belief8==1|belief9==1)
replace mono=0 if belief8==0 & (belief9==1)

gen switch=-1
replace switch=1 if mono==1 & belief1==0
replace switch=2 if mono==1 & belief1==1 & belief2==0
replace switch=3 if mono==1 & belief2==1 & belief3==0
replace switch=4 if mono==1 & belief3==1 & belief4==0
replace switch=5 if mono==1 & belief4==1 & belief5==0
replace switch=6 if mono==1 & belief5==1 & belief6==0
replace switch=7 if mono==1 & belief6==1 & belief7==0
replace switch=8 if mono==1 & belief7==1 & belief8==0
replace switch=9 if mono==1 & belief8==1 & belief9==0
replace switch=10 if mono==1 & belief9==1

gen uneq_income =0
replace uneq_income=-1 if decision<7
replace uneq_income=1 if decision>7

label define uneq_incomelabel 0 "IH=IL" -1 "IH>IL" 1 "IH<IL"
label values uneq_income uneq_incomelabel

gen uneq_util=0
replace uneq_util=-1 if ((decision+1 <switch & tr==1)|(decision<7 & tr==2)|(decision<7 & tr==3)|(decision+1 <switch & tr==4))
replace uneq_util=1 if ((decision>switch & tr==1)|(decision>switch & tr==4))

label define uneq_utillabel 0 "UH=UL" -1 "UH>UL" 1 "UH<UL"
label values uneq_util uneq_utillabel

eststo col0: estpost tab uneq_util uneq_income if tr==1 & mono==1 & dist==0
eststo col1: estpost tab uneq_util uneq_income if tr==1 & mono==1 & dist==1
esttab col0 col1 using `out'TableA5.tex, cell(colpct(fmt(0))) label substitute("\_" "_") unstack collabels(none) noobs nonumb  ///
varlabels(`e(labels)') eqlabels(`e(eqlabels)') ///
title("Utility Allocations in \$R^{H:work}_{L:wait}$ by Income Allocation (Mturk Sample)")  replace


eststo clear


gen utility_a=1
replace utility_a=2 if (decision+1<switch & tr==1)|(decision<7 & tr==2)|(decision<7 & tr==3)|(decision+1<switch & tr==4)
replace utility_a=3 if (decision>switch & tr==1)|(decision>7 & tr==2)|(decision>7 & tr==3)|(decision>switch & tr==4)

gen income_a =0
replace income_a=1 if decision<7
replace income_a=-1 if decision>7



************************************************************************************************************************************************

************************************************************************************************************************************************
*** Figure A5 ***

catplot tr utility_a if mono==1 & dist==0 & (tr==1|tr==2|tr==3), percent(tr) recast(bar) asyvars bar(1, color(white)  lcolor(navy) lwidth(medthick)) bar(2, color(olive_teal)) bar(3, color(forest_green)) legend(pos(1) ring(0) col(1) size(huge) order(1 2 3)) legend(label(1 "  {sub:H: Work}" "R{sub:L: Wait}") label(2 "  {sub:H: Wait}" "R{sub:L: Wait}") label(3 "  {sub:H: Work}" "R{sub:L: Work}") linegap(-1))  ytitle("Percentage") ylab(0 (20) 100, nogrid) yscale(titlegap(2)) var2opts(relabel(1`" "U{subscript:H} = U{subscript:L}" "' 2`" "U{subscript:H} > U{subscript:L}" "' 3`" "U{subscript:H} < U{subscript:L}" "')) graphregion(color(white)) plotregion(color(white))
graph export `out'FigureA5a.png, replace 

catplot tr utility_a if mono==1 & dist==1 & (tr==1|tr==2|tr==3), percent(tr) recast(bar) asyvars bar(1, color(white)  lcolor(navy) lwidth(medthick)) bar(2, color(olive_teal)) bar(3, color(forest_green)) legend(pos(1) ring(0) col(1) size(huge) order(1 2 3)) legend(label(1 "  {sub:H: Work}" "R{sub:L: Wait}") label(2 "  {sub:H: Wait}" "R{sub:L: Wait}") label(3 "  {sub:H: Work}" "R{sub:L: Work}") linegap(-1))  ytitle("Percentage") ylab(0 (20) 100, nogrid) yscale(titlegap(2)) var2opts(relabel(1`" "U{subscript:H} = U{subscript:L}" "' 2`" "U{subscript:H} > U{subscript:L}" "' 3`" "U{subscript:H} < U{subscript:L}" "')) graphregion(color(white)) plotregion(color(white))
graph export `out'FigureA5b.png, replace 



*******************************************************************************************************************************************************
******************************************************************** ROBUSTNESS STUDY ********************************************************************
*********************************************************************************************************************************************************

clear all


use `prolific'

label define conditionlabel 1 "LW-LS" 2 "LW-HS" 3 "HW-HS"
label values condition conditionlabel

label define trlabel 1 "\$R_{L: wait}^{H:work}$" 2 "\$R_{L: wait}^{H:wait}$" 3 "\$R_{L: work}^{H:work}$" 4 "\$E_{L: wait}^{H:work}$"
label values tr trlabel

** Generating Indicator for High Wage (1) - Low Wage (0) in Part 1**
gen hw=0
replace hw=1 if condition==3

** Generating Indicator for High Stake (1) - Low Stake (0) **
gen hs=0
replace hs=1 if condition>1

*** Implemented Inequality ***
gen s =0 
replace s= 0.75 if decision==1
replace s= 0.625 if decision==2
replace s= 0.5 if decision==3
replace s= 0.375 if decision==4
replace s= 0.25 if decision==5
replace s= 0.125 if decision==6

gen double H = 0
replace H= 1.40 if hs==0 & decision==1
replace H= 1.30 if hs==0 & decision==2
replace H= 1.20 if hs==0 & decision==3
replace H= 1.10 if hs==0 & decision==4
replace H= 1 	  if hs==0 & decision==5
replace H= 0.90 if hs==0 & decision==6
replace H= 0.80 if hs==0 & decision==7
replace H= 7    if hs==1 & decision==1
replace H= 6.50 if hs==1 & decision==2
replace H= 6    if hs==1 & decision==3
replace H= 5.50 if hs==1 & decision==4
replace H= 5	  if hs==1 & decision==5
replace H= 4.50 if hs==1 & decision==6
replace H= 4    if hs==1 & decision==7

*** Creating Dummy Variables for Demographics ***

gen female=1 
replace female=0 if gender==2

gen college=1
replace college=0 if education<5

gen conservative=0
replace conservative=1 if political==2

gen employed=0
replace employed=1 if (employment<4)	

************************************************************************************************************************************************

************************************************************************************************************************************************
************ Figure B5 **************

preserve

gen n=1

by condition tr, sort :egen mean_s= mean(s) 
by condition tr, sort :egen sd_s= sd(s)
by condition tr, sort :egen n_s= sum(n)
generate hi_s = mean_s + invttail(n_s-1,0.025)*(sd_s/ sqrt(n_s))
generate low_s = mean_s - invttail(n_s-1,0.025)*(sd_s/ sqrt(n_s))

generate range_tr = tr    if condition==1
replace  range_tr = tr+5  if condition==2
replace  range_tr = tr+10  if condition==3


twoway (bar mean_s range_tr if condition==1 & tr==1, bcolor(white) blcolor(navy) blwidth(medthick)) ///
	   (bar mean_s range_tr if condition==1 & tr==3, bcolor(forest_green)) ///
	   (bar mean_s range_tr if condition==2 & tr==1, bcolor(white) blcolor(navy) blwidth(medthick)) ///
	   (bar mean_s range_tr if condition==2 & tr==3, bcolor(forest_green)) ///
	   (bar mean_s range_tr if condition==3 & tr==1, bcolor(white) blcolor(navy) blwidth(medthick)) ///
	   (bar mean_s range_tr if condition==3 & tr==3, bcolor(forest_green)) ///
	   (rcap hi_s low_s range_tr, lcolor(red)), legend(pos(12) ring(0) col(2) size(large) order(1 2)) legend(label(1 "  {sub:H: Work}" "R{sub:L: Wait}") label(2 "  {sub:H: Work}" "R{sub:L: Work}") linegap(-1))  xtitle("") xlabel( 0.5 `" "Low Wage""Low Stake" "' 5.5 `" "Low Wage""High Stake" "' 10.5 `" "High Wage""High Stake" "', noticks labsize(large)) ytitle("Implemented Inequality", size(large)) ylabel(0(0.25)0.75, nogrid) plotregion(color(white)) graphregion(color(white)) 
graph export `out'FigureB5.png, replace 
	   
restore
	   
************************************************************************************************************************************************

************************************************************************************************************************************************
************ Figure B6 ************** 

gen mono=1
replace mono=0 if belief1==0 & (belief2==1|belief3==1|belief4==1|belief5==1|belief6==1|belief7==1|belief8==1|belief9==1)
replace mono=0 if belief2==0 & (belief3==1|belief4==1|belief5==1|belief6==1|belief7==1|belief8==1|belief9==1)
replace mono=0 if belief3==0 & (belief4==1|belief5==1|belief6==1|belief7==1|belief8==1|belief9==1)
replace mono=0 if belief4==0 & (belief5==1|belief6==1|belief7==1|belief8==1|belief9==1)
replace mono=0 if belief5==0 & (belief6==1|belief7==1|belief8==1|belief9==1)
replace mono=0 if belief6==0 & (belief7==1|belief8==1|belief9==1)
replace mono=0 if belief7==0 & (belief8==1|belief9==1)
replace mono=0 if belief8==0 & (belief9==1)

tab mono condition, column

preserve

keep prolific_pid belief1 belief2 belief3 belief4 belief5 belief6 belief7 belief8 belief9 mono condition tr 
reshape long belief, i(prolific_pid) j(guess)

by condition mono guess, sort: egen choosework= mean(belief)
twoway (connected choosework guess if condition==1 & mono==1, lcolor(black) lwidth(medthick)) (connected choosework guess if condition==2 & mono==1, lcolor(red) lpattern(dash) msymbol(triangle)) (connected choosework guess if condition==3 & mono==1, lcolor(gs8) lpattern(dot) msymbol(circle_hollow) mcolor(gs8)), legend( pos(7) ring(0) col(1) size(medlarge) order(1 "LW-LS" 2 "LW-HS" 3 "HW-HS")) xlab(1(1)9,nogrid labsize(medium)) ylab(0(0.2)1, labsize(medlarge) nogrid) xtitle("Payment Scenario", size(large) margin(medium))  ytitle("Fraction of Spectators" "guessing Agent chose to {it:Work}", size(medlarge)) xlabel(1 `" "1.40" "(7.00)" "0.20" "(1.00)" "' 2 `" "1.30" "(6.50)" "0.30" "(1.50)" "' 3 `" "1.20" "(6.00)" "0.40" "(2.00)" "' 4`" "1.10" "(5.50)" "0.50" "(2.50)" "' 5`" "1.00" "(5.00)" "0.60" "(3.00)" "' 6`" "0.90" "(4.50)" "0.70" "(3.50)" "' 7 `" "0.80" "(4.00)" "0.80" "(4.00)" "' 8`" "0.70" "(2.50)" "0.90" "(5.50)" "' 9 `" "0.60" "(3.00)" "1.00" "(5.00)" "') plotregion(color(white)) graphregion(color(white)) text(-0.12 0 "{it: Work:}") graphregion(margin(3 15 1 3)) text(-0.25 0 "{it: Wait:}") graphregion(margin(3 15 1 3))

graph export `out'FigureB6.png, replace 

restore 

************************************************************************************************************************************************

************************************************************************************************************************************************
************ Table B6 ************** 

reg s ib1.tr score1 age female college employed income if condition==1, robust
eststo m1
reg s ib1.tr score1 age female college employed income if condition==2, robust
eststo m2
reg s ib1.tr score1 age female college employed income if condition==3, robust
eststo m3
reg s ib1.tr##ib1.condition score1 age female college employed income, robust
eststo m4
esttab m1 m2 m3 m4 using `out'TableB6.tex ///
 	, b(2) se(2) label substitute("\_" "_") /// 
	title("Implemented Inequality") /// 
	mgroups ( "Implemented Inequality \$s_i$", pattern (1 0 0 0) prefix(\multicolumn{@span}{c}{) suffix(}) span ) ///
	mtitles ( "LW-LS" "LW-HS" "HW-HS" "Pooled") ///
	nogaps nonumbers compress /// 
	stats(N r2, labels ("No. of Obs." "R-Squared") fmt(0 2)) ///
 	star(* 0.10 ** 0.05 *** 0.01 )  /// 
	drop (score1 age female college employed income) ///
	nobaselevels interaction(" $\times$ ")style(tex) addnote("Robust SEs")  replace
	
eststo clear

************************************************************************************************************************************************

************************************************************************************************************************************************
******* Table B7 ***********

gen switch=-1
replace switch=1 if mono==1 & belief1==0
replace switch=2 if mono==1 & belief1==1 & belief2==0
replace switch=3 if mono==1 & belief2==1 & belief3==0
replace switch=4 if mono==1 & belief3==1 & belief4==0
replace switch=5 if mono==1 & belief4==1 & belief5==0
replace switch=6 if mono==1 & belief5==1 & belief6==0
replace switch=7 if mono==1 & belief6==1 & belief7==0
replace switch=8 if mono==1 & belief7==1 & belief8==0
replace switch=9 if mono==1 & belief8==1 & belief9==0
replace switch=10 if mono==1 & belief9==1


gen uneq_income =0
replace uneq_income=-1 if decision<7
replace uneq_income=1 if decision>7

label define uneq_incomelabel 0 "IH=IL" -1 "IH>IL" 1 "IH<IL"
label values uneq_income uneq_incomelabel

gen uneq_util=0
replace uneq_util=-1 if ((decision+1 <switch & tr==1)|(decision<7 & tr==2)|(decision<7 & tr==3)|(decision+1 <switch & tr==4))
replace uneq_util=1 if ((decision>switch & tr==1)|(decision>switch & tr==4))

label define uneq_utillabel 0 "UH=UL" -1 "UH>UL" 1 "UH<UL"
label values uneq_util uneq_utillabel


eststo col0: estpost tab uneq_util uneq_income if tr==1 & mono==1 & condition==1
eststo col1: estpost tab uneq_util uneq_income if tr==1 & mono==1 & condition==2
eststo col2: estpost tab uneq_util uneq_income if tr==1 & mono==1 & condition==3

esttab col0 col1 col2 using `out'TableB7.tex, cell(colpct(fmt(0))) label substitute("\_" "_") unstack noobs mtitles("LW-LS" "LW-HS" "HW-HS") collabels(none) ///
title("Utility Allocations in R\$_{H:work}^{L:wait}$ by Income Allocation (Robustness Study)") replace





